home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / TEX-UTIL / DVIPS_55 / dvips / special / lpro next >
Text File  |  1992-03-06  |  8KB  |  334 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %%     header for the \special command
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4. %   The structure of the PostScript produced by dvips for \special is:
  5. %         @beginspecial
  6. %           - any number of @hsize, @hoffset, @hscale, etc., commands
  7. %         @setspecial
  8. %           - the user's file of PostScript commands
  9. %         @endspecial
  10.  
  11. TeXDict begin
  12. /SDict 200 dict N
  13. SDict begin
  14.  
  15. /@SpecialDefaults
  16.   { /hs 612 N
  17.     /vs 792 N
  18.     /ho 0 N
  19.     /vo 0 N
  20.     /hsc 1 N
  21.     /vsc 1 N
  22.     /ang 0 N
  23.     /CLIP 0 N
  24.     /rwiSeen false N
  25.     /rhiSeen false N
  26.     /letter {} N /note {} N /a4 {} N /legal {} N
  27.   } B
  28.  
  29. %
  30. %   The following definition sets up the units that hscale/vscale are in.
  31. %   For certain sites this might require change, but it is
  32. %   recommended instead that any macro packages that require
  33. %   hscale/vscale set the units appropriately via
  34. %
  35. %   \special{! /@scaleunit 1 def }
  36. %
  37. %   if global, or
  38. %
  39. %   \special{" /@scaleunit 1 def }
  40. %
  41. %   before each instance if multiple macro packages with
  42. %   different requirements are being used.
  43. %
  44. /@scaleunit 100 N
  45. %       s @hscale  -    set scale factor
  46. /@hscale {@scaleunit div /hsc X} B
  47. /@vscale {@scaleunit div /vsc X} B
  48.  
  49. %       d @hsize   -    specify a horizontal clipping dimension
  50. /@hsize {/hs X /CLIP 1 N} B
  51. /@vsize {/vs X /CLIP 1 N} B
  52.  
  53. /@clip {/CLIP 2 N} B
  54.  
  55. %       d @hoffset -    specify a shift for the figure
  56. /@hoffset {/ho X} B
  57. /@voffset {/vo X} B
  58.  
  59. %       a @angle   -    set rotation angle
  60. /@angle {/ang X} B
  61.  
  62. %
  63. %   Here we handle bounding box calculations, if necessary.
  64. %
  65. /@rwi { 10 div /rwi X /rwiSeen true N } B % rwi will be real width after scaling
  66. /@rhi { 10 div /rhi X /rhiSeen true N } B % rhi will be real height after scaling
  67. /@llx { /llx X } B
  68. /@lly { /lly X } B
  69. /@urx { /urx X } B
  70. /@ury { /ury X } B
  71.  
  72. /magscale true def
  73.  
  74. end % of SDict
  75.  
  76. /@MacSetUp
  77.   { userdict /md known  % if md is defined
  78.       { userdict /md get type /dicttype eq      % and if it is a dictionary
  79.     {
  80.         userdict begin                       % expand it if necessary
  81.            md length 10 add md maxlength ge
  82.            {/md md dup length 20 add dict copy def}if
  83.         end
  84.     md begin                             % then redefine some stuff
  85.     /letter {} N
  86.     /note {} N
  87.     /legal {} N
  88.     /od{txpose
  89.         1 0 mtx defaultmatrix dtransform S atan/pa X
  90.         newpath clippath mark
  91.         {transform{itransform moveto}}
  92.         {transform{itransform lineto}}
  93.         { 6 -2 roll transform
  94.           6 -2 roll transform
  95.           6 -2 roll transform
  96.           { itransform 6 2 roll
  97.         itransform 6 2 roll
  98.         itransform 6 2 roll
  99.         curveto
  100.           }
  101.         }
  102.         {{closepath}}
  103.         pathforall newpath counttomark array astore /gc xdf
  104.         pop ct 39 0 put
  105.         10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if
  106.     }N
  107.     /txpose{
  108.         pxs pys scale ppr aload pop
  109.         por {
  110.         noflips {
  111.             pop S neg S TR pop 1 -1 scale
  112.         }if
  113.         xflip yflip and {
  114.             pop S neg S TR 180 rotate 1 -1 scale
  115.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  116.             ppr 0 get neg sub neg TR
  117.         }if 
  118.         xflip yflip not and {
  119.             pop S neg S TR pop 180 rotate
  120.             ppr 3 get ppr 1 get neg sub neg 0 TR
  121.         }if
  122.         yflip xflip not and {
  123.             ppr 1 get neg ppr 0 get neg TR
  124.         }if
  125.         }
  126.         {
  127.         noflips {
  128.             TR pop pop 270 rotate 1 -1 scale
  129.         }if
  130.         xflip yflip and {
  131.             TR pop pop 90 rotate 1 -1 scale
  132.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  133.             ppr 0 get neg sub neg TR
  134.         }if
  135.         xflip yflip not and {
  136.             TR pop pop 90 rotate ppr 3 get
  137.             ppr 1 get neg sub neg 0 TR
  138.         }if
  139.         yflip xflip not and {
  140.             TR pop pop 270 rotate ppr 2 get
  141.             ppr 0 get neg sub neg 0 S TR
  142.         }if
  143.         }ifelse
  144.         scaleby96 {
  145.         ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy
  146.         TR .96 dup scale neg S neg S TR
  147.         }if
  148.     }N
  149.     /cp {pop pop showpage pm restore}N
  150.         end
  151.       }if
  152.     } if    
  153.   } N
  154.  
  155. %
  156. %   The following procedure brings us back to PostScript size.  It takes
  157. %   into account the current global dvi magnification, so graphics
  158. %   scale with the document.
  159. %
  160. /normalscale {
  161.     Resolution 72 div VResolution 72 div neg scale
  162.     magscale { DVImag dup scale } if
  163.     0 setgray
  164. } N
  165. %
  166. %   We need the psfig macros.
  167. %
  168. % All software, documentation, and related files in this distribution of
  169. % psfig/tex are Copyright (c) 1987 Trevor J. Darrell
  170. %
  171. % Permission is granted for use and non-profit distribution of psfig/tex 
  172. % providing that this notice be clearly maintained, but the right to
  173. % distribute any portion of psfig/tex for profit or as part of any commercial
  174. % product is specifically reserved for the author.
  175. %
  176. %
  177. % psfigTeX PostScript Prolog
  178. % $Header: /usr/local/src/TeX/Dvips-5.0.2/RCS/special.lpro,v 1.1 90/03/10 20:32:57 grunwald Exp $
  179. %
  180. /psfts { S 65781.76 div N } N
  181.  
  182. %  x y bb-llx bb-lly bb-urx bb-ury startFig -
  183. /startTexFig {
  184.     /psf$SavedState save N
  185.     userdict maxlength dict begin
  186.  
  187.     /magscale false def
  188.     normalscale
  189.         currentpoint TR    %set the current point as the user's origin
  190.  
  191.     /psf$ury psfts
  192.     /psf$urx psfts
  193.     /psf$lly psfts
  194.     /psf$llx psfts
  195.     /psf$y psfts
  196.     /psf$x psfts
  197.     
  198.     currentpoint /psf$cy X /psf$cx X
  199.  
  200.     /psf$sx psf$x psf$urx psf$llx sub div N     % scaling for x
  201.     /psf$sy psf$y psf$ury psf$lly sub div N    % scaling for y
  202.  
  203.     psf$sx psf$sy scale            % scale by (sx,sy)
  204.  
  205.     psf$cx psf$sx div psf$llx sub
  206.     psf$cy psf$sy div psf$ury sub TR
  207.     
  208.     /showpage {
  209.     } N
  210.     /erasepage {
  211.     } N
  212.     /copypage {
  213.     } N
  214.         /p 3 def % necessary to get around a bug in Adobe Illustrator
  215.     @MacSetUp
  216. } N
  217.  
  218. % llx lly urx ury doclip -    (args in figure coordinates)
  219. /doclip {
  220.         psf$llx psf$lly psf$urx psf$ury
  221.     currentpoint 6 2 roll
  222.     newpath 4 copy
  223.     4 2 roll moveto
  224.     6 -1 roll S lineto
  225.     S lineto
  226.     S lineto
  227.     closepath clip
  228.     newpath
  229.     moveto
  230. } N
  231. % - endTexFig -
  232. /endTexFig { end psf$SavedState restore } N
  233.  
  234. % this will be invoked as the result of a \special command (for the
  235. % inclusion of PostScript graphics).  The basic idea is to change all
  236. % scaling and graphics back to defaults, but to shift the origin
  237. % to the current position on the page.
  238.  
  239. /@beginspecial          % - @beginspecial -     -- enter special mode
  240.   { SDict begin
  241.     /SpecialSave save N
  242.     gsave
  243.     normalscale
  244.     currentpoint TR    %set the current point as the user's origin
  245.     @SpecialDefaults    % setup default offsets, scales, sizes, and angle
  246.     count /ocount X /dcount countdictstack N
  247.   } N
  248.  
  249. /@setspecial    % to setup user specified offsets, scales, sizes (for clipping)
  250.   {
  251.     CLIP 1 eq
  252.       { newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto 
  253.         closepath clip }
  254.     if
  255.     ho vo TR
  256.     hsc vsc scale
  257.     ang rotate
  258.     rwiSeen {
  259.        rwi urx llx sub div
  260.        rhiSeen { rhi ury lly sub div } { dup } ifelse
  261.        scale llx neg lly neg TR
  262.     } {
  263.        rhiSeen { rhi ury lly sub div dup scale llx neg lly neg TR } if
  264.     } ifelse
  265.     CLIP 2 eq
  266.     { newpath llx lly moveto urx lly lineto urx ury lineto llx ury lineto
  267.       closepath clip }
  268.     if
  269.     /showpage {} N
  270.     /erasepage {} N
  271.     /copypage {} N
  272.     newpath
  273.   } N
  274.  
  275. /@endspecial            % - @endspecial -       -- leave special mode
  276.   { count ocount sub {pop} repeat
  277.     countdictstack dcount sub {end} repeat
  278.     grestore SpecialSave restore
  279.     end
  280.   } N
  281. /@defspecial
  282.   {
  283.     SDict begin
  284.   } N
  285. /@fedspecial
  286.   {
  287.     end
  288.   } B
  289.  
  290. %%% macros for tpic
  291. /li             % x y li -              -- draw line to
  292.   { lineto
  293.   } B
  294.  
  295. /rl             % dx dy rl -            -- draw relative line
  296.   { rlineto
  297.   } B
  298.  
  299. /rc             % x0 y0 x1 y1 y2 y2 rc  -- draw bezier curve
  300.   { rcurveto
  301.   } B
  302.  
  303. /np        % np -            -- start a new path and save currentpoint
  304.   { /SaveX currentpoint /SaveY X N   % remember current point
  305.     1 setlinecap
  306.     newpath
  307.   } N
  308.  
  309. /st             % st -                  -- draw the last path and restore currentpoint
  310.   { stroke
  311.     SaveX SaveY moveto                  % restore the current point
  312.   } N
  313.  
  314. /fil             % fil                    -- fill the last path and restore currentpoint
  315.   { fill
  316.     SaveX SaveY moveto                  % restore the current point
  317.   } N
  318.  
  319. /ellipse        % xc yc xrad yrad startAngle endAngle ellipse
  320.     {
  321.         /endangle X
  322.         /startangle X
  323.         /yrad X
  324.         /xrad X
  325.  
  326.         /savematrix matrix currentmatrix N
  327.  
  328.         TR xrad yrad scale
  329.         0 0 1 startangle endangle arc
  330.         savematrix setmatrix
  331.     } N
  332. %%% end of macros for tpic
  333. end                     % revert to previous dictionary
  334.